package com.study.whyyy.config;

import com.study.whyyy.interceptor.IdempotentInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 在 Spring Boot 配置文件类中，添加拦截器配置
 *
 * @author whyyy
 * @create 2025/2/13 15:47
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Resource
    private IdempotentInterceptor idempotentInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 拦截所有接口
        registry.addInterceptor(idempotentInterceptor).addPathPatterns("/**");
    }
}
